const mongoose = require('./db');
const { getId } = require ( '../utils/getMethods' )

// 获取城市列表
const regionListSchema = new mongoose.Schema({
	regionId: {					// 城市id
		type: Number,
		default: () => getId
	},
	regionName: {					// 城市名称	
		type: String,
		required: true
	},
	
})

const leaderAddressContentSchema = new mongoose.Schema({
	id: {
		type: Number,
		default: () => getId
	},
	takeName: {
		type: String,
		required: true
	},
	location: {
		type: Object
	},
	storePath: {
		type: String,
		required: true
	},
	detailAddress: {
		type: String,
		required: true
	},
	distance: {
		type: Number,
		required: true
	}
})

// 获取店铺列表
const leaderAddressSchema = new mongoose.Schema({
	userId: {						// 用户id
		type: Number,
		default: () => getId
	},
	leaderId: {						// 店主id
		type: Number,
		default: () => getId
	},
	leaderName: String,				// 店主
	leaderPhone: String,			// 店主电话
	takeName: {						// 提货店名
		type: String,
		required: true
	},
	detailAddress: {					// 详细地址	
		type: String,
		required: true
	},		
	longitude: {					// 经度
		type: Number
	},
	latitude: {						// 纬度
		type: Number
	},
	storePath: {					// 店铺图片
		type: String,
		required: true
	},
	distance:Number,
	regionName: String,
	id:Number,
})

const regionListModel = mongoose.model('regionList', regionListSchema, 'regionList')
// const leaderAddressContentModel = mongoose.model('leaderAddress', leaderAddressContentSchema, 'leaderAddress')
const leaderAddressModel = mongoose.model('leaderAddress', leaderAddressSchema, 'leaderAddress')

module.exports = {
	leaderAddressModel,
	// leaderAddressContentModel,
	regionListModel
}